/**
 * 错误码已经挪到 jh-3rd/config/tipConfig.js 进行维护
 * @type {{}}
 */
const tipConfig = window.tipConfig || {};

export default tipConfig;

export function formatTip(status, parameters) {
    const locale = window.localStorage.getItem('umi_locale') || 'zh-CN';
    const tipO = tipConfig[`${status}`] || {};
    return formatCheckErr(tipO[locale], parameters) || '';
}

export const formatCheckErr = function(errMsg, paramObj) {
    let reMsg = errMsg;

    if ('string' === typeof reMsg && paramObj) {

        for (const k in paramObj) {

            if (paramObj.hasOwnProperty(k)) {
                const val = paramObj[k];
                reMsg = reMsg.replace(eval(`/\{${k}\}/g`), val);
            }
        }
    }
    return reMsg;
};
